export default {
  data () {
    return {
      exchangeRate: 0
    }
  },
  watch: {
    langKey () {
      this.exchangeCurrency()
    }
  },
  methods: {
    exchangeCurrency () {
      this.exchangeRate = 0
      let rateFlag = ''
      switch (this.langKey) {
        case 'zh-CN':
          rateFlag = 'USDCNY'
          break
        case 'vi':
          rateFlag = 'USDVND'
          break
      }
      rateFlag && this.$http.post('CurrencyExchangeRate/GetExchageRate', {
        pair: rateFlag
      }).then((res) => {
        if (res.isOk && res.Data[0].FixedRate) {
          this.exchangeRate = res.Data[0].FixedRate
        }
      })
    }
  }
}
